package crp.core.course.domain.models;

import com.qwlabs.auditing.AuditedEntity;
import crp.core.shared.Tables;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Getter
@Setter
@Entity
@Table(name = Tables.COURSE)
public class CourseEntity extends AuditedEntity {
    @Id
    @GeneratedValue(generator = "UUID")
    @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
    private String id;
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    private PlanCourseEntity planCourse;
    private String code;
    private String name;
    private String teachingClassCode;
    @OneToOne(mappedBy = "course", cascade = CascadeType.ALL, optional = false)
    private CourseAttributesEntity attributes;
}
